//百度统计
var _hmt = _hmt || []
;(function () {
  var hm = document.createElement('script')
  hm.src = '//hm.baidu.com/hm.js?c3e519f2b38b77d61bde2a133f8d782c'
  var s = document.getElementsByTagName('script')[0]
  s.parentNode.insertBefore(hm, s)
})()

//神策
function getCookie(key) {
  var cookie = document.cookie
  var arr = cookie.split('; ')
  for (var i = 0; i < arr.length; i++) {
    var newArr = arr[i].split('=')
    if (key == newArr[0]) {
      return newArr[1]
    }
  }
}
function getParams(key) {
  let search = window.location.href.split('?')[1]
  if (search) {
    let searchObject = search.split('&').reduce(function (pre, cur) {
      var [k, v] = cur.split('=')
      return {
        ...pre,
        [k]: v
      }
    }, {})
    return searchObject[key]
  } else {
    return ''
  }
}
;(function (para) {
  var p = para.sdk_url,
    n = para.name,
    w = window,
    d = document,
    s = 'script',
    x = null,
    y = null
  if (typeof w['sensorsDataAnalytic201505'] !== 'undefined') {
    return false
  }
  w['sensorsDataAnalytic201505'] = n
  w[n] =
    w[n] ||
    function (a) {
      return function () {
        ;(w[n]._q = w[n]._q || []).push([a, arguments])
      }
    }
  var ifs = [
    'track',
    'quick',
    'register',
    'registerPage',
    'registerOnce',
    'trackSignup',
    'trackAbtest',
    'setProfile',
    'setOnceProfile',
    'appendProfile',
    'incrementProfile',
    'deleteProfile',
    'unsetProfile',
    'identify',
    'login',
    'logout',
    'trackLink',
    'clearAllRegister',
    'getAppStatus'
  ]
  for (var i = 0; i < ifs.length; i++) {
    w[n][ifs[i]] = w[n].call(null, ifs[i])
  }
  if (!w[n]._t) {
    ;(x = d.createElement(s)), (y = d.getElementsByTagName(s)[0])
    x.async = 1
    x.src = p
    x.setAttribute('charset', 'UTF-8')
    w[n].para = para
    y.parentNode.insertBefore(x, y)
  }
})({
  sdk_url: 'https://a1.gystatic.com/v6/js/libs/sensorsdata/1.17.1/sensorsdata.min.js',
  heatmap_url: 'https://a1.gystatic.com/v6/js/libs/sensorsdata/1.17.1/heatmap.min.js',
  name: 'sensors',
  app_js_bridge: true,
  show_log: false,
  send_type: 'beacon',
  server_url: 'https://sensorsdata-api.banksteel.com/sa?project=production',
  heatmap: {scroll_notice_map: 'not_collect'}
})
// 注册公共属性
sensors.registerPage({
  ua: navigator.userAgent,
})
var isMiniProgram = window.navigator.userAgent.toLowerCase().indexOf('miniprogram') != -1
var isUniapp = window.navigator.userAgent.toLowerCase().indexOf('uni-app') != -1
if (isMiniProgram) {
  var distinctID = getParams('distinctID')
  if (distinctID) {
    sensors.identify(distinctID, true)
    sensors.registerPage({
      platform: 'miniprogram',
    })
  }
}else if(isUniapp){
  sensors.registerPage({
    platform: 'app',
  })
}else{
  sensors.registerPage({
    platform: 'web',
  })
}
// if(getCookie("user_token")){
// sensors.login(getCookie("loginUID"),function(){
// //回调函数的使用需要 SDK 版本大于等于 1.14.8
// });
// }
sensors.quick('autoTrack')
